package com.taotao.content.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.content.service.ContentService;
import com.taotao.mapper.TbContentMapper;
import com.taotao.pojo.TbContent;
import com.taotao.pojo.TbContentExample;
import com.taotao.pojo.TbContentExample.Criteria;

import pojo.TaotaoResult;
@Service
public class ContentServiceimpl implements ContentService {
	//内容例表新增
	@Autowired
	private TbContentMapper tbContentMapper;
	@Override
	public TaotaoResult insertContent(TbContent tbContent) {
		tbContent.setUpdated(new Date());
		tbContent.setCreated(new Date());
		tbContentMapper.insert(tbContent);
		return TaotaoResult.ok();
	}
	//首页轮播图
	@Override
	public List<TbContent> getContentList(long cid) {
		TbContentExample example =new TbContentExample();
		 Criteria criteria = example.createCriteria();
		criteria.andCategoryIdEqualTo(cid);
		List<TbContent> list = tbContentMapper.selectByExample(example);
		return list;
	}

}
